package com.google.code.mochaccino.framework.security;
/**
 * Copyright 2012 Claude Houle claude.houle@gmail.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import javax.inject.Inject;
import org.apache.shiro.realm.Realm;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.apache.shiro.web.mgt.WebSecurityManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Security Manager Provider. Albeit this prepares a security manager that is ready for
 * operation within a ServletContainer, you still requires to se the SecurityFilter as
 * part of the Servlet Filter List, otherwise there will never be ANY subject available
 * to the executing thread.
 */
public final class SecurityManagerProviderWeb extends SecurityManagerProvider<WebSecurityManager> {

	private Logger logger = LoggerFactory.getLogger( getClass() );

	@Inject
	public SecurityManagerProviderWeb( Realm[] realmList ) {
		super( realmList );
	}

	@Override
	public WebSecurityManager get() {
		DefaultWebSecurityManager bean = new DefaultWebSecurityManager( getRealmList() );
		configure( bean );
		return bean;
	}
}
